﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
namespace Common
{
    public class LogHelper
    {
        private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");   //选择<logger name="loginfo">的配置  
        private static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");   //选择<logger name="logerror">的配置
        private static readonly log4net.ILog logsearchinfo = log4net.LogManager.GetLogger("logsearchinfo");
        private static readonly log4net.ILog logtestinfo = log4net.LogManager.GetLogger("logtestinfo"); //专门给测试用的配置
        private static readonly log4net.ILog logpayinfo = log4net.LogManager.GetLogger("logpayinfo");//支付日志
        public static void SetConfig()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        public static void SetConfig(FileInfo configFile)
        {
            log4net.Config.XmlConfigurator.Configure(configFile);
        }

        public static void WriteInfoLog(string info)
        {
            if (loginfo.IsInfoEnabled)
            {
                loginfo.Info(info);
            }
        }

        public static void WriteErrorLog(string info, Exception se)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Error(info, se);
            }
        }
        public static void WriteSearchLog(string info)
        {
            if (logsearchinfo.IsInfoEnabled)
            {
                logsearchinfo.Info(info);
            }
        }
        /// <summary>
        /// 专门给测试用的配置
        /// </summary>
        /// <param name="info"></param>
        public static void WriteTestLog(string info)
        {
            if (logtestinfo.IsInfoEnabled)
            {
                logtestinfo.Info(info);
            }
        }
        /// <summary>
        /// 用于支付的日志
        /// </summary>
        /// <param name="info"></param>
        public static void WriteB2CPayAppenderInfoLog(string info)
        {
            if (logpayinfo.IsInfoEnabled)
            {
                logpayinfo.Info(info);
            }
        }
    }  
}
